<!DOCTYPE html>
<html lang="en">
    <head prefix="og: http://ogp.me/ns# article: http://ogp.me/ns/article#">
    <meta charset="UTF-8" />

    <meta name="generator" content="Hugo 0.81.0" /><meta name="theme-color" content="#fff" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    
    <meta name="format-detection" content="telephone=no, date=no, address=no, email=no" />
    
    <meta http-equiv="Cache-Control" content="no-transform" />
    
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>Java中使用HSSFWorkbook生成excel | blog</title>

    <link rel="stylesheet" href="/css/meme.min.9ceadc8ab1656ff9471d988ec901d9c83d5aca953748a9c4dc867747c8aadcd8.css"/>

    
    
        <script src="https://cdn.jsdelivr.net/npm/lunr@2.3.9/lunr.min.js" defer></script><script src="/js/meme.min.ff5d4cf818e61f9aa68fc2960767a64242469990791a256a47227a6c234ed7b1.js"></script>

    

    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

        <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=EB&#43;Garamond:ital,wght@0,400;0,500;0,700;1,400;1,700&amp;family=Noto&#43;Serif&#43;SC:wght@400;500;700&amp;family=Source&#43;Code&#43;Pro:ital,wght@0,400;0,700;1,400;1,700&amp;display=swap" media="print" onload="this.media='all'" />
        <noscript><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=EB&#43;Garamond:ital,wght@0,400;0,500;0,700;1,400;1,700&amp;family=Noto&#43;Serif&#43;SC:wght@400;500;700&amp;family=Source&#43;Code&#43;Pro:ital,wght@0,400;0,700;1,400;1,700&amp;display=swap" /></noscript>

    <meta name="author" content="古月轩039" /><meta name="description" content="HSSFWorkbook 介绍 开发中经常会遇到 Excel 的处理，在 Java 中，操作 excel 目前有两个主流框架，分别是： apache 的 poi Apache POI…" />

    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="mask-icon" href="/icons/safari-pinned-tab.svg" color="#2a6df4" />
    <link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-title" content="blog" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="mobile-web-app-capable" content="yes" />
    <meta name="application-name" content="blog" />
    <meta name="msapplication-starturl" content="../" />
    <meta name="msapplication-TileColor" content="#fff" />
    <meta name="msapplication-TileImage" content="../icons/mstile-150x150.png" />
    <link rel="manifest" href="/manifest.json" />

    
    

    
    <link rel="canonical" href="https://my-hugo-blog-latin-xiao-mao.vercel.app/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/" />
    

<script type="application/ld+json">
    {
        "@context": "https://schema.org",
        "@type": "BlogPosting",
        "datePublished": "2021-03-12T22:40:47+08:00",
        "dateModified": "2021-03-12T22:50:27+08:00",
        "url": "https://my-hugo-blog-latin-xiao-mao.vercel.app/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/",
        "headline": "Java中使用HSSFWorkbook生成excel",
        "description": "HSSFWorkbook 介绍 开发中经常会遇到 Excel 的处理，在 Java 中，操作 excel 目前有两个主流框架，分别是： apache 的 poi Apache POI…",
        "inLanguage" : "en",
        "articleSection": "posts",
        "wordCount":  2758 ,
        "image": ["https://img.imgdb.cn/item/604b7e335aedab222ce6192e.jpg","https://img.imgdb.cn/item/604b7e335aedab222ce61937.jpg","https://img.imgdb.cn/item/604b7e335aedab222ce61945.jpg"],
        "author": {
            "@type": "Person",
            "description": "往事既已成过往，便随它而去吧。",
            "email": "reuixiy@gmail.com",
            "image": "https://my-hugo-blog-latin-xiao-mao.vercel.app/icons/apple-touch-icon.png",
            "url": "https://io-oi.me/",
            "name": "古月轩039"
        },
        "license": "[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)",
        "publisher": {
            "@type": "Organization",
            "name": "blog",
            "logo": {
                "@type": "ImageObject",
                "url": "https://my-hugo-blog-latin-xiao-mao.vercel.app/icons/apple-touch-icon.png"
            },
            "url": "https://my-hugo-blog-latin-xiao-mao.vercel.app/"
        },
        "mainEntityOfPage": {
            "@type": "WebSite",
            "@id": "https://my-hugo-blog-latin-xiao-mao.vercel.app/"
        }
    }
</script>

    

<meta name="twitter:card" content="summary_large_image" />


<meta name="twitter:site" content="@reuixiy" />
<meta name="twitter:creator" content="@reuixiy" />

    



<meta property="og:title" content="Java中使用HSSFWorkbook生成excel" />
<meta property="og:description" content="HSSFWorkbook 介绍 开发中经常会遇到 Excel 的处理，在 Java 中，操作 excel 目前有两个主流框架，分别是： apache 的 poi Apache POI…" />
<meta property="og:url" content="https://my-hugo-blog-latin-xiao-mao.vercel.app/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/" />
<meta property="og:site_name" content="blog" />
<meta property="og:locale" content="en" /><meta property="og:image" content="https://img.imgdb.cn/item/604b7e335aedab222ce6192e.jpg" />
<meta property="og:type" content="article" />
    <meta property="article:published_time" content="2021-03-12T22:40:47&#43;08:00" />
    <meta property="article:modified_time" content="2021-03-12T22:50:27&#43;08:00" />
    
    <meta property="article:section" content="posts" />



    
</head>

    <body>
        <div class="container">
            
    <header class="header">
        
            <div class="header-wrapper">
                <div class="header-inner single">
                    
    <div class="site-brand">
        
            <a href="/" class="brand">blog</a>
        
    </div>

                    <nav class="nav">
    <ul class="menu" id="menu">
        
            
        
        
        
        
            
                <li class="menu-item"><a href="/posts/"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon archive"><path d="M32 448c0 17.7 14.3 32 32 32h384c17.7 0 32-14.3 32-32V160H32v288zm160-212c0-6.6 5.4-12 12-12h104c6.6 0 12 5.4 12 12v8c0 6.6-5.4 12-12 12H204c-6.6 0-12-5.4-12-12v-8zM480 32H32C14.3 32 0 46.3 0 64v48c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16V64c0-17.7-14.3-32-32-32z"/></svg><span class="menu-item-name">posts</span></a>
                </li>
            
        
            
                <li class="menu-item"><a href="/categories/"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon th"><path d="M149.333 56v80c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V56c0-13.255 10.745-24 24-24h101.333c13.255 0 24 10.745 24 24zm181.334 240v-80c0-13.255-10.745-24-24-24H205.333c-13.255 0-24 10.745-24 24v80c0 13.255 10.745 24 24 24h101.333c13.256 0 24.001-10.745 24.001-24zm32-240v80c0 13.255 10.745 24 24 24H488c13.255 0 24-10.745 24-24V56c0-13.255-10.745-24-24-24H386.667c-13.255 0-24 10.745-24 24zm-32 80V56c0-13.255-10.745-24-24-24H205.333c-13.255 0-24 10.745-24 24v80c0 13.255 10.745 24 24 24h101.333c13.256 0 24.001-10.745 24.001-24zm-205.334 56H24c-13.255 0-24 10.745-24 24v80c0 13.255 10.745 24 24 24h101.333c13.255 0 24-10.745 24-24v-80c0-13.255-10.745-24-24-24zM0 376v80c0 13.255 10.745 24 24 24h101.333c13.255 0 24-10.745 24-24v-80c0-13.255-10.745-24-24-24H24c-13.255 0-24 10.745-24 24zm386.667-56H488c13.255 0 24-10.745 24-24v-80c0-13.255-10.745-24-24-24H386.667c-13.255 0-24 10.745-24 24v80c0 13.255 10.745 24 24 24zm0 160H488c13.255 0 24-10.745 24-24v-80c0-13.255-10.745-24-24-24H386.667c-13.255 0-24 10.745-24 24v80c0 13.255 10.745 24 24 24zM181.333 376v80c0 13.255 10.745 24 24 24h101.333c13.255 0 24-10.745 24-24v-80c0-13.255-10.745-24-24-24H205.333c-13.255 0-24 10.745-24 24z"/></svg><span class="menu-item-name">categories</span></a>
                </li>
            
        
            
                <li class="menu-item"><a href="/tags/"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" class="icon tags"><path d="M497.941 225.941L286.059 14.059A48 48 0 0 0 252.118 0H48C21.49 0 0 21.49 0 48v204.118a48 48 0 0 0 14.059 33.941l211.882 211.882c18.744 18.745 49.136 18.746 67.882 0l204.118-204.118c18.745-18.745 18.745-49.137 0-67.882zM112 160c-26.51 0-48-21.49-48-48s21.49-48 48-48 48 21.49 48 48-21.49 48-48 48zm513.941 133.823L421.823 497.941c-18.745 18.745-49.137 18.745-67.882 0l-.36-.36L527.64 323.522c16.999-16.999 26.36-39.6 26.36-63.64s-9.362-46.641-26.36-63.64L331.397 0h48.721a48 48 0 0 1 33.941 14.059l211.882 211.882c18.745 18.745 18.745 49.137 0 67.882z"/></svg><span class="menu-item-name">tags</span></a>
                </li>
            
        
            
                <li class="menu-item"><a href="/about/"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512" class="icon user-circle"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 96c48.6 0 88 39.4 88 88s-39.4 88-88 88-88-39.4-88-88 39.4-88 88-88zm0 344c-58.7 0-111.3-26.6-146.5-68.2 18.8-35.4 55.6-59.8 98.5-59.8 2.4 0 4.8.4 7.1 1.1 13 4.2 26.6 6.9 40.9 6.9 14.3 0 28-2.7 40.9-6.9 2.3-.7 4.7-1.1 7.1-1.1 42.9 0 79.7 24.4 98.5 59.8C359.3 421.4 306.7 448 248 448z"/></svg><span class="menu-item-name">about</span></a>
                </li>
            
        
            
                
                    
                    
                        <li class="menu-item">
                            <a id="theme-switcher" href="#"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon theme-icon-light"><path d="M193.2 104.5l48.8-97.5a18 18 0 0128 0l48.8 97.5 103.4 -34.5a18 18 0 0119.8 19.8l-34.5 103.4l97.5 48.8a18 18 0 010 28l-97.5 48.8 34.5 103.4a18 18 0 01-19.8 19.8l-103.4-34.5-48.8 97.5a18 18 0 01-28 0l-48.8-97.5l-103.4 34.5a18 18 0 01-19.8-19.8l34.5-103.4-97.5-48.8a18 18 0 010-28l97.5-48.8-34.5-103.4a18 18 0 0119.8-19.8zM256 128a128 128 0 10.01 0M256 160a96 96 0 10.01 0"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon theme-icon-dark"><path d="M27 412a256 256 0 10154-407a11.5 11.5 0 00-5 20a201.5 201.5 0 01-134 374a11.5 11.5 0 00-15 13"/></svg></a>
                        </li>
                    
                
            
        
            
                
            
        
    </ul>
</nav>

                    
                </div>
            </div>
            
    <input type="checkbox" id="nav-toggle" aria-hidden="true" />
    <label for="nav-toggle" class="nav-toggle"></label>
    <label for="nav-toggle" class="nav-curtain"></label>


        
    </header>




            
            
    <main class="main single" id="main">
    <div class="main-inner">

        

        <article class="content post h-entry" data-align="justify" data-type="posts" data-toc-num="true">

            <h1 class="post-title p-name">Java中使用HSSFWorkbook生成excel</h1>

            

            
                
            

            
                

<div class="post-meta">
    
        
        <time datetime="2021-03-12T22:40:47&#43;08:00" class="post-meta-item published dt-published"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="icon post-meta-icon"><path d="M148 288h-40c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12zm108-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm-96 96v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm-96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm192 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96-260v352c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V112c0-26.5 21.5-48 48-48h48V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h128V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h48c26.5 0 48 21.5 48 48zm-48 346V160H48v298c0 3.3 2.7 6 6 6h340c3.3 0 6-2.7 6-6z"/></svg>&nbsp;2021.3.12</time>
    
    
        
        <time datetime="2021-03-12T22:50:27&#43;08:00" class="post-meta-item modified dt-updated"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="icon post-meta-icon"><path d="M400 64h-48V12c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v52H160V12c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v52H48C21.49 64 0 85.49 0 112v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm-6 400H54a6 6 0 0 1-6-6V160h352v298a6 6 0 0 1-6 6zm-52.849-200.65L198.842 404.519c-4.705 4.667-12.303 4.637-16.971-.068l-75.091-75.699c-4.667-4.705-4.637-12.303.068-16.971l22.719-22.536c4.705-4.667 12.303-4.637 16.97.069l44.104 44.461 111.072-110.181c4.705-4.667 12.303-4.637 16.971.068l22.536 22.718c4.667 4.705 4.636 12.303-.069 16.97z"/></svg>&nbsp;2021.3.12</time>
    
    
    
        
        
        
            
                <span class="post-meta-item category"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon post-meta-icon"><path d="M464 128H272l-54.63-54.63c-6-6-14.14-9.37-22.63-9.37H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V176c0-26.51-21.49-48-48-48zm0 272H48V112h140.12l54.63 54.63c6 6 14.14 9.37 22.63 9.37H464v224z"/></svg>&nbsp;<a href="/categories/%E7%BC%96%E7%A8%8B/" class="category-link p-category">编程</a></span>
            
        
    
    
        
        <span class="post-meta-item wordcount"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon post-meta-icon"><path d="M497.9 142.1l-46.1 46.1c-4.7 4.7-12.3 4.7-17 0l-111-111c-4.7-4.7-4.7-12.3 0-17l46.1-46.1c18.7-18.7 49.1-18.7 67.9 0l60.1 60.1c18.8 18.7 18.8 49.1 0 67.9zM284.2 99.8L21.6 362.4.4 483.9c-2.9 16.4 11.4 30.6 27.8 27.8l121.5-21.3 262.6-262.6c4.7-4.7 4.7-12.3 0-17l-111-111c-4.8-4.7-12.4-4.7-17.1 0zM124.1 339.9c-5.5-5.5-5.5-14.3 0-19.8l154-154c5.5-5.5 14.3-5.5 19.8 0s5.5 14.3 0 19.8l-154 154c-5.5 5.5-14.3 5.5-19.8 0zM88 424h48v36.3l-64.5 11.3-31.1-31.1L51.7 376H88v48z"/></svg>&nbsp;2758</span>
    
    
        
        <span class="post-meta-item reading-time"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon post-meta-icon"><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200zm61.8-104.4l-84.9-61.7c-3.1-2.3-4.9-5.9-4.9-9.7V116c0-6.6 5.4-12 12-12h32c6.6 0 12 5.4 12 12v141.7l66.8 48.6c5.4 3.9 6.5 11.4 2.6 16.8L334.6 349c-3.9 5.3-11.4 6.5-16.8 2.6z"/></svg>&nbsp;6&nbsp;mins</span>
    
    
    
</div>

            

            <div class="post-body e-content">
              <p><img src="https://img.imgdb.cn/item/604b7e335aedab222ce6192e.jpg" alt=""></p>
<h1 id="hssfworkbook-介绍"><a href="#hssfworkbook-介绍" class="anchor-link"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon anchor-icon"><path d="M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"/></svg></a>HSSFWorkbook 介绍</h1>
<hr>
<p>开发中经常会遇到 Excel 的处理，在 Java 中，操作 excel 目前有两个主流框架，分别是：</p>
<ul>
<li>apache 的 poi</li>
</ul>
<blockquote>
<p>Apache POI [1]  是用Java编写的免费开源的跨平台的 Java API，Apache POI提供API给Java程式对Microsoft Office格式档案读和写的功能。POI为“Poor Obfuscation Implementation”的首字母缩写，意为“简洁版的模糊实现”。</p>
</blockquote>
<ul>
<li>Java Excel</li>
</ul>
<blockquote>
<p>Java Excel是一开放源码项目，通过它Java开发人员可以读取Excel文件的内容、创建新的Excel文件、更新已经存在的Excel文件。jxl 由于其小巧 易用的特点, 逐渐已经取代了 POI-excel的地位, 成为了越来越多的java开发人员生成excel文件的首选</p>
</blockquote>
<p>这里提一下：HSSFWorkbook:是操作Excel2003以前（包括2003）的版本，扩展名是.xls；XSSFWorkbook:是操作Excel2007的版本，扩展名是.xlsx。对于不同版本的EXCEL文档要使用不同的工具类，如果使用错了，会提示如下错误信息：org.apache.poi.openxml4j.exceptions.InvalidOperationException，org.apache.poi.poifs.filesystem.OfficeXmlFileException</p>
<p><img src="https://img.imgdb.cn/item/604b7e335aedab222ce61937.jpg" alt=""></p>
<h1 id="hssfworkbook-的使用"><a href="#hssfworkbook-的使用" class="anchor-link"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon anchor-icon"><path d="M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"/></svg></a>HSSFWorkbook 的使用</h1>
<hr>
<div class="highlight"><div class="chroma">
<div class="table-container"><table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">  1
</span><span class="lnt">  2
</span><span class="lnt">  3
</span><span class="lnt">  4
</span><span class="lnt">  5
</span><span class="lnt">  6
</span><span class="lnt">  7
</span><span class="lnt">  8
</span><span class="lnt">  9
</span><span class="lnt"> 10
</span><span class="lnt"> 11
</span><span class="lnt"> 12
</span><span class="lnt"> 13
</span><span class="lnt"> 14
</span><span class="lnt"> 15
</span><span class="lnt"> 16
</span><span class="lnt"> 17
</span><span class="lnt"> 18
</span><span class="lnt"> 19
</span><span class="lnt"> 20
</span><span class="lnt"> 21
</span><span class="lnt"> 22
</span><span class="lnt"> 23
</span><span class="lnt"> 24
</span><span class="lnt"> 25
</span><span class="lnt"> 26
</span><span class="lnt"> 27
</span><span class="lnt"> 28
</span><span class="lnt"> 29
</span><span class="lnt"> 30
</span><span class="lnt"> 31
</span><span class="lnt"> 32
</span><span class="lnt"> 33
</span><span class="lnt"> 34
</span><span class="lnt"> 35
</span><span class="lnt"> 36
</span><span class="lnt"> 37
</span><span class="lnt"> 38
</span><span class="lnt"> 39
</span><span class="lnt"> 40
</span><span class="lnt"> 41
</span><span class="lnt"> 42
</span><span class="lnt"> 43
</span><span class="lnt"> 44
</span><span class="lnt"> 45
</span><span class="lnt"> 46
</span><span class="lnt"> 47
</span><span class="lnt"> 48
</span><span class="lnt"> 49
</span><span class="lnt"> 50
</span><span class="lnt"> 51
</span><span class="lnt"> 52
</span><span class="lnt"> 53
</span><span class="lnt"> 54
</span><span class="lnt"> 55
</span><span class="lnt"> 56
</span><span class="lnt"> 57
</span><span class="lnt"> 58
</span><span class="lnt"> 59
</span><span class="lnt"> 60
</span><span class="lnt"> 61
</span><span class="lnt"> 62
</span><span class="lnt"> 63
</span><span class="lnt"> 64
</span><span class="lnt"> 65
</span><span class="lnt"> 66
</span><span class="lnt"> 67
</span><span class="lnt"> 68
</span><span class="lnt"> 69
</span><span class="lnt"> 70
</span><span class="lnt"> 71
</span><span class="lnt"> 72
</span><span class="lnt"> 73
</span><span class="lnt"> 74
</span><span class="lnt"> 75
</span><span class="lnt"> 76
</span><span class="lnt"> 77
</span><span class="lnt"> 78
</span><span class="lnt"> 79
</span><span class="lnt"> 80
</span><span class="lnt"> 81
</span><span class="lnt"> 82
</span><span class="lnt"> 83
</span><span class="lnt"> 84
</span><span class="lnt"> 85
</span><span class="lnt"> 86
</span><span class="lnt"> 87
</span><span class="lnt"> 88
</span><span class="lnt"> 89
</span><span class="lnt"> 90
</span><span class="lnt"> 91
</span><span class="lnt"> 92
</span><span class="lnt"> 93
</span><span class="lnt"> 94
</span><span class="lnt"> 95
</span><span class="lnt"> 96
</span><span class="lnt"> 97
</span><span class="lnt"> 98
</span><span class="lnt"> 99
</span><span class="lnt">100
</span><span class="lnt">101
</span><span class="lnt">102
</span><span class="lnt">103
</span><span class="lnt">104
</span><span class="lnt">105
</span><span class="lnt">106
</span><span class="lnt">107
</span><span class="lnt">108
</span><span class="lnt">109
</span><span class="lnt">110
</span><span class="lnt">111
</span><span class="lnt">112
</span><span class="lnt">113
</span><span class="lnt">114
</span><span class="lnt">115
</span><span class="lnt">116
</span><span class="lnt">117
</span><span class="lnt">118
</span><span class="lnt">119
</span><span class="lnt">120
</span><span class="lnt">121
</span><span class="lnt">122
</span><span class="lnt">123
</span><span class="lnt">124
</span><span class="lnt">125
</span><span class="lnt">126
</span><span class="lnt">127
</span><span class="lnt">128
</span><span class="lnt">129
</span><span class="lnt">130
</span><span class="lnt">131
</span><span class="lnt">132
</span><span class="lnt">133
</span><span class="lnt">134
</span><span class="lnt">135
</span><span class="lnt">136
</span><span class="lnt">137
</span><span class="lnt">138
</span><span class="lnt">139
</span><span class="lnt">140
</span><span class="lnt">141
</span><span class="lnt">142
</span><span class="lnt">143
</span><span class="lnt">144
</span><span class="lnt">145
</span><span class="lnt">146
</span><span class="lnt">147
</span><span class="lnt">148
</span><span class="lnt">149
</span><span class="lnt">150
</span><span class="lnt">151
</span><span class="lnt">152
</span><span class="lnt">153
</span><span class="lnt">154
</span><span class="lnt">155
</span><span class="lnt">156
</span><span class="lnt">157
</span><span class="lnt">158
</span><span class="lnt">159
</span><span class="lnt">160
</span><span class="lnt">161
</span><span class="lnt">162
</span><span class="lnt">163
</span><span class="lnt">164
</span><span class="lnt">165
</span><span class="lnt">166
</span><span class="lnt">167
</span><span class="lnt">168
</span><span class="lnt">169
</span><span class="lnt">170
</span><span class="lnt">171
</span><span class="lnt">172
</span><span class="lnt">173
</span><span class="lnt">174
</span><span class="lnt">175
</span><span class="lnt">176
</span><span class="lnt">177
</span><span class="lnt">178
</span><span class="lnt">179
</span><span class="lnt">180
</span><span class="lnt">181
</span><span class="lnt">182
</span><span class="lnt">183
</span><span class="lnt">184
</span><span class="lnt">185
</span><span class="lnt">186
</span><span class="lnt">187
</span><span class="lnt">188
</span><span class="lnt">189
</span><span class="lnt">190
</span><span class="lnt">191
</span><span class="lnt">192
</span><span class="lnt">193
</span><span class="lnt">194
</span><span class="lnt">195
</span><span class="lnt">196
</span><span class="lnt">197
</span><span class="lnt">198
</span><span class="lnt">199
</span><span class="lnt">200
</span><span class="lnt">201
</span><span class="lnt">202
</span><span class="lnt">203
</span><span class="lnt">204
</span><span class="lnt">205
</span><span class="lnt">206
</span><span class="lnt">207
</span><span class="lnt">208
</span><span class="lnt">209
</span><span class="lnt">210
</span><span class="lnt">211
</span><span class="lnt">212
</span><span class="lnt">213
</span><span class="lnt">214
</span><span class="lnt">215
</span><span class="lnt">216
</span><span class="lnt">217
</span><span class="lnt">218
</span><span class="lnt">219
</span><span class="lnt">220
</span><span class="lnt">221
</span><span class="lnt">222
</span><span class="lnt">223
</span><span class="lnt">224
</span><span class="lnt">225
</span><span class="lnt">226
</span><span class="lnt">227
</span><span class="lnt">228
</span><span class="lnt">229
</span><span class="lnt">230
</span><span class="lnt">231
</span><span class="lnt">232
</span><span class="lnt">233
</span><span class="lnt">234
</span><span class="lnt">235
</span><span class="lnt">236
</span><span class="lnt">237
</span><span class="lnt">238
</span><span class="lnt">239
</span><span class="lnt">240
</span><span class="lnt">241
</span><span class="lnt">242
</span><span class="lnt">243
</span><span class="lnt">244
</span><span class="lnt">245
</span><span class="lnt">246
</span><span class="lnt">247
</span><span class="lnt">248
</span><span class="lnt">249
</span><span class="lnt">250
</span><span class="lnt">251
</span><span class="lnt">252
</span><span class="lnt">253
</span><span class="lnt">254
</span><span class="lnt">255
</span><span class="lnt">256
</span><span class="lnt">257
</span><span class="lnt">258
</span><span class="lnt">259
</span><span class="lnt">260
</span><span class="lnt">261
</span><span class="lnt">262
</span><span class="lnt">263
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="kn">package</span> <span class="nn">com.knowledge.point</span><span class="o">;</span>

<span class="kn">import</span> <span class="nn">org.apache.poi.hssf.usermodel.*</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.apache.poi.ss.usermodel.Font</span><span class="o">;</span>

<span class="kn">import</span> <span class="nn">java.io.*</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">java.util.ArrayList</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">java.util.HashMap</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">java.util.Map</span><span class="o">;</span>

<span class="cm">/**
</span><span class="cm"> * @author: latinos-bub
</span><span class="cm"> * @date: 2019/11/12 17:32
</span><span class="cm"> * @description: 测试生成 excel
</span><span class="cm"> * @className: com.knowledge.point.TestGenExcel
</span><span class="cm"> */</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="nc">TestGenExcel</span> <span class="o">{</span>

    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span><span class="o">{</span>

        <span class="c1">// 创建一个 excel 工作簿
</span><span class="c1"></span>        <span class="n">HSSFWorkbook</span> <span class="n">workbook</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HSSFWorkbook</span><span class="o">();</span>

        <span class="c1">// 创建一个 excel 里面的 sheet 表格，并设置 sheet 名字
</span><span class="c1"></span>        <span class="n">HSSFSheet</span> <span class="n">sheet</span> <span class="o">=</span> <span class="n">workbook</span><span class="o">.</span><span class="na">createSheet</span><span class="o">(</span><span class="s">&#34;测试生成 excel 表格是否乱码&#34;</span><span class="o">);</span>

        <span class="c1">// -------------------------------设置 工作簿的 样式 start--------------------------//
</span><span class="c1"></span>        <span class="n">HSSFCellStyle</span> <span class="n">titleStyle</span>  <span class="o">=</span> <span class="n">workbook</span><span class="o">.</span><span class="na">createCellStyle</span><span class="o">();</span> <span class="c1">// 创建标题样式
</span><span class="c1"></span>        <span class="n">titleStyle</span><span class="o">.</span><span class="na">setAlignment</span><span class="o">(</span><span class="n">HSSFCellStyle</span><span class="o">.</span><span class="na">ALIGN_CENTER</span><span class="o">);</span>    <span class="c1">// 设置标题水平居中显示
</span><span class="c1"></span>        <span class="n">titleStyle</span><span class="o">.</span><span class="na">setVerticalAlignment</span><span class="o">(</span><span class="n">HSSFCellStyle</span><span class="o">.</span><span class="na">VERTICAL_CENTER</span><span class="o">);</span> <span class="c1">// 设置标题垂直居中显示
</span><span class="c1"></span>        <span class="n">HSSFFont</span> <span class="n">titleFont</span> <span class="o">=</span> <span class="n">workbook</span><span class="o">.</span><span class="na">createFont</span><span class="o">();</span>    <span class="c1">// 创建标题字体
</span><span class="c1"></span>        <span class="n">titleFont</span><span class="o">.</span><span class="na">setItalic</span><span class="o">(</span><span class="kc">false</span><span class="o">);</span>                     <span class="c1">// 设置字体为斜体字
</span><span class="c1"></span>        <span class="n">titleFont</span><span class="o">.</span><span class="na">setColor</span><span class="o">(</span><span class="n">Font</span><span class="o">.</span><span class="na">COLOR_RED</span><span class="o">);</span>            <span class="c1">// 将字体设置为“红色”
</span><span class="c1"></span>        <span class="n">titleFont</span><span class="o">.</span><span class="na">setFontHeightInPoints</span><span class="o">((</span><span class="kt">short</span><span class="o">)</span><span class="n">16</span><span class="o">);</span>    <span class="c1">// 将字体大小设置为18px
</span><span class="c1"></span>        <span class="n">titleFont</span><span class="o">.</span><span class="na">setFontName</span><span class="o">(</span><span class="s">&#34;宋体&#34;</span><span class="o">);</span>             <span class="c1">// 将“宋体”字体应用到当前单元格上
</span><span class="c1"></span>        <span class="n">titleFont</span><span class="o">.</span><span class="na">setBoldweight</span><span class="o">(</span><span class="n">HSSFFont</span><span class="o">.</span><span class="na">BOLDWEIGHT_BOLD</span><span class="o">);</span>    <span class="c1">//加粗
</span><span class="c1"></span>        <span class="n">titleStyle</span><span class="o">.</span><span class="na">setFont</span><span class="o">(</span><span class="n">titleFont</span><span class="o">);</span> <span class="c1">// 将 字体应用到 标题样式上
</span><span class="c1"></span>
        <span class="n">HSSFCellStyle</span> <span class="n">cellStyle</span>  <span class="o">=</span> <span class="n">workbook</span><span class="o">.</span><span class="na">createCellStyle</span><span class="o">();</span>  <span class="c1">// 创建 cell 单元格样式
</span><span class="c1"></span>        <span class="n">cellStyle</span><span class="o">.</span><span class="na">setAlignment</span><span class="o">(</span><span class="n">HSSFCellStyle</span><span class="o">.</span><span class="na">ALIGN_CENTER</span><span class="o">);</span> <span class="c1">// 设置 cell 单元格水平居中显示
</span><span class="c1"></span>        <span class="n">cellStyle</span><span class="o">.</span><span class="na">setVerticalAlignment</span><span class="o">(</span><span class="n">HSSFCellStyle</span><span class="o">.</span><span class="na">VERTICAL_CENTER</span><span class="o">);</span>  <span class="c1">// 设置 cell 单元格垂直居中显示
</span><span class="c1"></span>        <span class="n">Font</span> <span class="n">cellFont</span> <span class="o">=</span> <span class="n">workbook</span><span class="o">.</span><span class="na">createFont</span><span class="o">();</span>  <span class="c1">// 创建 单元格 字体
</span><span class="c1"></span>        <span class="n">cellFont</span><span class="o">.</span><span class="na">setFontHeightInPoints</span><span class="o">((</span><span class="kt">short</span><span class="o">)</span><span class="n">10</span><span class="o">);</span>    <span class="c1">// 将字体大小设置为18px
</span><span class="c1"></span>        <span class="n">cellFont</span><span class="o">.</span><span class="na">setFontName</span><span class="o">(</span><span class="s">&#34;宋体&#34;</span><span class="o">);</span>             <span class="c1">// 字体应用到当前单元格上
</span><span class="c1"></span>        <span class="n">cellStyle</span><span class="o">.</span><span class="na">setFont</span><span class="o">(</span><span class="n">cellFont</span><span class="o">);</span> <span class="c1">// 将 字体应用到 单元格样式上
</span><span class="c1"></span>        <span class="c1">// -------------------------------设置 工作簿的 样式 end--------------------------//
</span><span class="c1"></span>


        <span class="c1">// 创建 首行(即标题 行)
</span><span class="c1"></span>        <span class="n">HSSFRow</span> <span class="n">headRow</span> <span class="o">=</span> <span class="n">sheet</span><span class="o">.</span><span class="na">createRow</span><span class="o">(</span><span class="n">0</span><span class="o">);</span>
        <span class="c1">// 创建 首行(即标题 行) 的 第一个单元格
</span><span class="c1"></span>        <span class="n">HSSFCell</span> <span class="n">headCell</span> <span class="o">=</span> <span class="n">headRow</span><span class="o">.</span><span class="na">createCell</span><span class="o">(</span><span class="n">0</span><span class="o">);</span>
        <span class="c1">// 设置 首行(即标题 行)的文字内容
</span><span class="c1"></span>        <span class="n">headCell</span><span class="o">.</span><span class="na">setCellValue</span><span class="o">(</span><span class="s">&#34;更新时间&#34;</span><span class="o">);</span>
        <span class="n">headCell</span><span class="o">.</span><span class="na">setCellStyle</span><span class="o">(</span><span class="n">titleStyle</span><span class="o">);</span> <span class="c1">// 设置 首行的 第一个单元格 样式
</span><span class="c1"></span>        <span class="c1">// 创建 首行(即标题 行) 的 第二个单元格
</span><span class="c1"></span>        <span class="n">headCell</span> <span class="o">=</span> <span class="n">headRow</span><span class="o">.</span><span class="na">createCell</span><span class="o">(</span><span class="n">1</span><span class="o">);</span>
        <span class="n">headCell</span><span class="o">.</span><span class="na">setCellValue</span><span class="o">(</span><span class="s">&#34;创建时间&#34;</span><span class="o">);</span>
        <span class="n">headCell</span><span class="o">.</span><span class="na">setCellStyle</span><span class="o">(</span><span class="n">titleStyle</span><span class="o">);</span>  <span class="c1">// 这里一定要每次实例化之后都要设置样式
</span><span class="c1"></span>        <span class="n">headCell</span> <span class="o">=</span> <span class="n">headRow</span><span class="o">.</span><span class="na">createCell</span><span class="o">(</span><span class="n">2</span><span class="o">);</span>
        <span class="n">headCell</span><span class="o">.</span><span class="na">setCellValue</span><span class="o">(</span><span class="s">&#34;删除状态&#34;</span><span class="o">);</span>
        <span class="n">headCell</span><span class="o">.</span><span class="na">setCellStyle</span><span class="o">(</span><span class="n">titleStyle</span><span class="o">);</span> <span class="c1">// 这里一定要每次实例化之后都要设置样式
</span><span class="c1"></span>        <span class="n">headCell</span> <span class="o">=</span> <span class="n">headRow</span><span class="o">.</span><span class="na">createCell</span><span class="o">(</span><span class="n">3</span><span class="o">);</span>
        <span class="n">headCell</span><span class="o">.</span><span class="na">setCellValue</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">);</span>
        <span class="n">headCell</span><span class="o">.</span><span class="na">setCellStyle</span><span class="o">(</span><span class="n">titleStyle</span><span class="o">);</span> <span class="c1">// 这里一定要每次实例化之后都要设置样式
</span><span class="c1"></span>        <span class="n">headCell</span> <span class="o">=</span> <span class="n">headRow</span><span class="o">.</span><span class="na">createCell</span><span class="o">(</span><span class="n">4</span><span class="o">);</span>
        <span class="n">headCell</span><span class="o">.</span><span class="na">setCellValue</span><span class="o">(</span><span class="s">&#34;书名&#34;</span><span class="o">);</span>
        <span class="n">headCell</span><span class="o">.</span><span class="na">setCellStyle</span><span class="o">(</span><span class="n">titleStyle</span><span class="o">);</span> <span class="c1">// 这里一定要每次实例化之后都要设置样式
</span><span class="c1"></span>

        <span class="c1">// 获取 模拟的 List&lt;Map&lt;String, Object&gt; 数据
</span><span class="c1"></span>        <span class="n">List</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">list</span> <span class="o">=</span> <span class="n">getList</span><span class="o">();</span>

        <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="n">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">list</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++){</span>  <span class="c1">// 外层for是每一行的设置
</span><span class="c1"></span>            <span class="c1">// 每一行(填充的内容行)时，我们都要新实例化一个 HSSRow 新行
</span><span class="c1"></span>            <span class="n">HSSFRow</span> <span class="n">contentRow</span> <span class="o">=</span> <span class="n">sheet</span><span class="o">.</span><span class="na">createRow</span><span class="o">(</span><span class="n">sheet</span><span class="o">.</span><span class="na">getLastRowNum</span><span class="o">()</span> <span class="o">+</span> <span class="n">1</span><span class="o">);</span>    <span class="c1">// 调用sheet的上次最后一行索引 + 1即可
</span><span class="c1"></span>            <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">j</span> <span class="o">=</span> <span class="n">0</span><span class="o">;</span> <span class="n">j</span> <span class="o">&lt;</span> <span class="n">5</span><span class="o">;</span> <span class="n">j</span><span class="o">++){</span>    <span class="c1">// 内层 for 是 每行的 列数设置，因为我们的标题行有5列，所以这里设置5列
</span><span class="c1"></span>                <span class="c1">// 每一行，我们都要在该行(即contentRow) 实例化 5 个 cell 单元格
</span><span class="c1"></span>                <span class="n">HSSFCell</span> <span class="n">contentCell</span> <span class="o">=</span> <span class="n">contentRow</span><span class="o">.</span><span class="na">createCell</span><span class="o">(</span><span class="n">j</span><span class="o">);</span>
                <span class="k">switch</span> <span class="o">(</span><span class="n">j</span><span class="o">){</span> <span class="c1">// 1，2，3，4，5个单元格分别写入自己正确的数据
</span><span class="c1"></span>                    <span class="k">case</span> <span class="n">0</span><span class="o">:</span> <span class="c1">// 每一行的第一列(即第一个cell)我们都写入 update_time 对应的数据，以下依次类推
</span><span class="c1"></span>                        <span class="n">contentCell</span><span class="o">.</span><span class="na">setCellValue</span><span class="o">(</span><span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">list</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">get</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">)));</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="k">case</span> <span class="n">1</span><span class="o">:</span>
                        <span class="n">contentCell</span><span class="o">.</span><span class="na">setCellValue</span><span class="o">(</span><span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">list</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">get</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">)));</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="k">case</span> <span class="n">2</span><span class="o">:</span>
                        <span class="n">contentCell</span><span class="o">.</span><span class="na">setCellValue</span><span class="o">(</span><span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">list</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">get</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">)));</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="k">case</span> <span class="n">3</span><span class="o">:</span>
                        <span class="n">contentCell</span><span class="o">.</span><span class="na">setCellValue</span><span class="o">(</span><span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">list</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">get</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">)));</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="k">case</span> <span class="n">4</span><span class="o">:</span>
                        <span class="n">contentCell</span><span class="o">.</span><span class="na">setCellValue</span><span class="o">(</span><span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">list</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">get</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">)));</span>
                        <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="c1">// 设置 内容 居中显示 样式
</span><span class="c1"></span>                <span class="n">contentCell</span><span class="o">.</span><span class="na">setCellStyle</span><span class="o">(</span><span class="n">cellStyle</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="c1">// 设置 列 的宽度
</span><span class="c1"></span>        <span class="n">sheet</span><span class="o">.</span><span class="na">setColumnWidth</span><span class="o">(</span><span class="n">0</span><span class="o">,</span> <span class="n">900</span> <span class="o">*</span> <span class="n">10</span><span class="o">);</span>
        <span class="n">sheet</span><span class="o">.</span><span class="na">setColumnWidth</span><span class="o">(</span><span class="n">1</span><span class="o">,</span> <span class="n">900</span> <span class="o">*</span> <span class="n">10</span><span class="o">);</span>
        <span class="n">sheet</span><span class="o">.</span><span class="na">setColumnWidth</span><span class="o">(</span><span class="n">2</span><span class="o">,</span> <span class="n">900</span> <span class="o">*</span> <span class="n">10</span><span class="o">);</span>
        <span class="n">sheet</span><span class="o">.</span><span class="na">setColumnWidth</span><span class="o">(</span><span class="n">3</span><span class="o">,</span> <span class="n">900</span> <span class="o">*</span> <span class="n">10</span><span class="o">);</span>
        <span class="n">sheet</span><span class="o">.</span><span class="na">setColumnWidth</span><span class="o">(</span><span class="n">4</span><span class="o">,</span> <span class="n">900</span> <span class="o">*</span> <span class="n">10</span><span class="o">);</span>


        <span class="n">File</span> <span class="n">xlsFile</span> <span class="o">=</span> <span class="k">new</span> <span class="n">File</span><span class="o">(</span><span class="s">&#34;测试生成Excel.xls&#34;</span><span class="o">);</span>
        <span class="n">workbook</span><span class="o">.</span><span class="na">write</span><span class="o">(</span><span class="k">new</span> <span class="n">FileOutputStream</span><span class="o">(</span><span class="n">xlsFile</span><span class="o">));</span>
        <span class="n">workbook</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>


        <span class="c1">// 补充：如果是 web 程序，需要页面打开一个对话框，保存文件则，需要额外添加以下代码即可
</span><span class="c1"></span>        <span class="cm">/*String fileName = &#34;excel表&#34;;
</span><span class="cm">        fileName = new String(fileName.getBytes(), &#34;ISO-8859-1&#34;);
</span><span class="cm">        HttpServletResponse response = this.getResponse().getHttpResponse();
</span><span class="cm">        response.setHeader(&#34;Content-disposition&#34;, &#34;attachment; filename=&#34; + fileName + &#34;.xls&#34;);
</span><span class="cm">        response.setContentType(&#34;application/application/vnd.ms-excel;charset=utf-8&#34;);
</span><span class="cm">        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
</span><span class="cm">        // workbook 工作簿中写入数据
</span><span class="cm">        workbook.write(byteArrayOutputStream);
</span><span class="cm">        byte[] content = byteArrayOutputStream.toByteArray();
</span><span class="cm">        InputStream inputStream = new ByteArrayInputStream(content);
</span><span class="cm">        ServletOutputStream out = null;
</span><span class="cm">        try {
</span><span class="cm">            out = response.getOutputStream();
</span><span class="cm">            byte[] b = new byte[2048];  // 设置 缓冲区的读取字节大小
</span><span class="cm">            int i;
</span><span class="cm">            while ((i = inputStream.read(b)) &gt; 0) {
</span><span class="cm">                out.write(b, 0, i);
</span><span class="cm">            }
</span><span class="cm">            out.flush();
</span><span class="cm">        } catch (Exception e) {
</span><span class="cm">            System.out.println(&#34;生成excel表格时出错: &#34; + e.getMessage());
</span><span class="cm">        } finally {
</span><span class="cm">            if (inputStream != null)
</span><span class="cm">                inputStream.close();
</span><span class="cm">            if (out != null)
</span><span class="cm">                out.close();
</span><span class="cm">        }*/</span>
    <span class="o">}</span>




    <span class="cm">/**
</span><span class="cm">    * @Author latinos-bub
</span><span class="cm">    * @Description //TODO   这里我先准备一个从别的地方获取的 sql 结果集合，以备下面写入数据使用
</span><span class="cm">     * 这个 List 中我们就存放 12 个 Map 即可(模拟数据)
</span><span class="cm">    * @Date 2019/11/12 21:17
</span><span class="cm">    * @Param []
</span><span class="cm">    * @return java.util.List&lt;java.util.Map&lt;java.lang.String,java.lang.Object&gt;&gt;
</span><span class="cm">    **/</span>
    <span class="kd">private</span> <span class="kd">static</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="nf">getList</span><span class="o">(){</span>

        <span class="n">List</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">list</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map1</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569404166000&#34;</span><span class="o">);</span>
        <span class="n">map1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569404122000&#34;</span><span class="o">);</span>
        <span class="n">map1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;1&#34;</span><span class="o">);</span>
        <span class="n">map1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;2&#34;</span><span class="o">);</span>
        <span class="n">map1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;如何削铁&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map1</span><span class="o">);</span>

        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map2</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1509357581000&#34;</span><span class="o">);</span>
        <span class="n">map2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1508893725000&#34;</span><span class="o">);</span>
        <span class="n">map2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;1&#34;</span><span class="o">);</span>
        <span class="n">map2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;5&#34;</span><span class="o">);</span>
        <span class="n">map2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;莎士比亚&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map2</span><span class="o">);</span>

        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map3</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1510970055000&#34;</span><span class="o">);</span>
        <span class="n">map3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1508986168000&#34;</span><span class="o">);</span>
        <span class="n">map3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;1&#34;</span><span class="o">);</span>
        <span class="n">map3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;6&#34;</span><span class="o">);</span>
        <span class="n">map3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;亚里士多德&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map3</span><span class="o">);</span>


        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map4</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map4</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1510118932000&#34;</span><span class="o">);</span>
        <span class="n">map4</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1509001065000&#34;</span><span class="o">);</span>
        <span class="n">map4</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;1&#34;</span><span class="o">);</span>
        <span class="n">map4</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;10&#34;</span><span class="o">);</span>
        <span class="n">map4</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;亚历山大&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map4</span><span class="o">);</span>


        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map5</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map5</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1509002622000&#34;</span><span class="o">);</span>
        <span class="n">map5</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1509002622000&#34;</span><span class="o">);</span>
        <span class="n">map5</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;0&#34;</span><span class="o">);</span>
        <span class="n">map5</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;11&#34;</span><span class="o">);</span>
        <span class="n">map5</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;李白&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map5</span><span class="o">);</span>


        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map6</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map6</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569376168000&#34;</span><span class="o">);</span>
        <span class="n">map6</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569404290000&#34;</span><span class="o">);</span>
        <span class="n">map6</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;1&#34;</span><span class="o">);</span>
        <span class="n">map6</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;12&#34;</span><span class="o">);</span>
        <span class="n">map6</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;无用是什么&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map6</span><span class="o">);</span>

        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map7</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map7</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569376160000&#34;</span><span class="o">);</span>
        <span class="n">map7</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569404290000&#34;</span><span class="o">);</span>
        <span class="n">map7</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;0&#34;</span><span class="o">);</span>
        <span class="n">map7</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;13&#34;</span><span class="o">);</span>
        <span class="n">map7</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;选择吃什么饭是一件很痛苦的事&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map7</span><span class="o">);</span>

        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map8</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map8</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1510983431000&#34;</span><span class="o">);</span>
        <span class="n">map8</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1510983427000&#34;</span><span class="o">);</span>
        <span class="n">map8</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;1&#34;</span><span class="o">);</span>
        <span class="n">map8</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;19&#34;</span><span class="o">);</span>
        <span class="n">map8</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;文章test2&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map8</span><span class="o">);</span>

        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map9</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map9</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569376164000&#34;</span><span class="o">);</span>
        <span class="n">map9</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569404290000&#34;</span><span class="o">);</span>
        <span class="n">map9</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;1&#34;</span><span class="o">);</span>
        <span class="n">map9</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;20&#34;</span><span class="o">);</span>
        <span class="n">map9</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;就像选择在哪里睡觉一样&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map9</span><span class="o">);</span>

        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map10</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map10</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569376166000&#34;</span><span class="o">);</span>
        <span class="n">map10</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569404290000&#34;</span><span class="o">);</span>
        <span class="n">map10</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;1&#34;</span><span class="o">);</span>
        <span class="n">map10</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;21&#34;</span><span class="o">);</span>
        <span class="n">map10</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;effective of java&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map10</span><span class="o">);</span>

        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map11</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map11</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569376172000&#34;</span><span class="o">);</span>
        <span class="n">map11</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569404290000&#34;</span><span class="o">);</span>
        <span class="n">map11</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;1&#34;</span><span class="o">);</span>
        <span class="n">map11</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;22&#34;</span><span class="o">);</span>
        <span class="n">map11</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;荒岛求生&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map11</span><span class="o">);</span>

        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">map12</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
        <span class="n">map12</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;update_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569376170000&#34;</span><span class="o">);</span>
        <span class="n">map12</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;create_time&#34;</span><span class="o">,</span> <span class="s">&#34;1569404290000&#34;</span><span class="o">);</span>
        <span class="n">map12</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;delete_status&#34;</span><span class="o">,</span> <span class="s">&#34;0&#34;</span><span class="o">);</span>
        <span class="n">map12</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;id&#34;</span><span class="o">,</span> <span class="s">&#34;23&#34;</span><span class="o">);</span>
        <span class="n">map12</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&#34;content&#34;</span><span class="o">,</span> <span class="s">&#34;天使永远就在身边&#34;</span><span class="o">);</span>
        <span class="n">list</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">map12</span><span class="o">);</span>

        <span class="k">return</span> <span class="n">list</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">}</span>

</code></pre></td></tr></table></div>
</div>
</div><hr>
<p><img src="https://img.imgdb.cn/item/604b7e335aedab222ce61945.jpg" alt=""></p>
<div align="middle">《行香子·归去来兮》
	-- 北宋：辛弃疾
</div>
<blockquote>
<p>归去来兮，行乐休迟。命由天、富贵何时。
百年光景，七十者稀。奈一番愁，一番病，一番衰。
名利奔驰，宠辱惊疑。旧家时、都有些儿。
而今老矣，识破关机。算不如闲，不如醉，不如痴。</p>
</blockquote>

            </div>

            
    
    
        <ul class="post-copyright">
            <li class="copyright-item author"><span class="copyright-item-text">Author</span>: <a href="https://io-oi.me/" class="p-author h-card" target="_blank" rel="noopener">古月轩039</a></li>
            
                
                
                
                
                <li class="copyright-item link"><span class="copyright-item-text">Link</span>: <a href="/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/" target="_blank" rel="noopener">https://my-hugo-blog-latin-xiao-mao.vercel.app/java中使用hssfworkbook生成excel/</a></li>
            
            <li class="copyright-item license"><span class="copyright-item-text">License</span>: <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" target="_blank" rel="noopener">CC BY-NC-SA 4.0</a></li>
            
        </ul>
    



        </article>

        

        
    <div class="updated-badge-container">
        <span title="Updated @ 2021-03-12 22:50:27 CST" style="cursor:help">

<svg xmlns="http://www.w3.org/2000/svg" width="130" height="20" class="updated-badge"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="130" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path class="updated-badge-left" d="M0 0h55v20H0z"/><path class="updated-badge-right" d="M55 0h75v20H55z"/><path fill="url(#b)" d="M0 0h130v20H0z"/></g><g fill="#fff" text-anchor="middle" font-size="110"><text x="285" y="150" fill="#010101" fill-opacity=".3" textLength="450" transform="scale(.1)">updated</text><text x="285" y="140" textLength="450" transform="scale(.1)">updated</text><text x="915" y="150" fill="#010101" fill-opacity=".3" textLength="650" transform="scale(.1)">2021-03-12</text><text x="915" y="140" textLength="650" transform="scale(.1)">2021-03-12</text></g></svg>
        </span></div>



        


        <div class="post-share">

        

        <div class="share-items">

            
                <div class="share-item twitter">
                    
                    <a href="https://twitter.com/share?url=https://my-hugo-blog-latin-xiao-mao.vercel.app/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/&amp;text=Java%e4%b8%ad%e4%bd%bf%e7%94%a8HSSFWorkbook%e7%94%9f%e6%88%90excel&amp;hashtags=Java,&amp;via=reuixiy" title="Share on Twitter" target="_blank" rel="noopener"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon twitter-icon"><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"/></svg></a>
                </div>
            

            
                <div class="share-item facebook">
                    
                    <a href="https://www.facebook.com/sharer/sharer.php?u=https://my-hugo-blog-latin-xiao-mao.vercel.app/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/&amp;hashtag=%23Java" title="Share on Facebook" target="_blank" rel="noopener"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon facebook-icon"><path d="M504 256C504 119 393 8 256 8S8 119 8 256c0 123.78 90.69 226.38 209.25 245V327.69h-63V256h63v-54.64c0-62.15 37-96.48 93.67-96.48 27.14 0 55.52 4.84 55.52 4.84v61h-31.28c-30.8 0-40.41 19.12-40.41 38.73V256h68.78l-11 71.69h-57.78V501C413.31 482.38 504 379.78 504 256z"/></svg></a>
                </div>
            

            
                <div class="share-item linkedin">
                    
                    <a href="https://www.linkedin.com/shareArticle?mini=true&amp;url=https://my-hugo-blog-latin-xiao-mao.vercel.app/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/&amp;title=Java%e4%b8%ad%e4%bd%bf%e7%94%a8HSSFWorkbook%e7%94%9f%e6%88%90excel&amp;summary=HSSFWorkbook%20%e4%bb%8b%e7%bb%8d%20%e5%bc%80%e5%8f%91%e4%b8%ad%e7%bb%8f%e5%b8%b8%e4%bc%9a%e9%81%87%e5%88%b0%20Excel%20%e7%9a%84%e5%a4%84%e7%90%86%ef%bc%8c%e5%9c%a8%20Java%20%e4%b8%ad%ef%bc%8c%e6%93%8d%e4%bd%9c%20excel%20%e7%9b%ae%e5%89%8d%e6%9c%89%e4%b8%a4%e4%b8%aa%e4%b8%bb%e6%b5%81%e6%a1%86%e6%9e%b6%ef%bc%8c%e5%88%86%e5%88%ab%e6%98%af%ef%bc%9a%20apache%20%e7%9a%84%20poi%20Apache%20POI%e2%80%a6&amp;source=blog" title="Share on LinkedIn" target="_blank" rel="noopener"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="icon linkedin-icon"><path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z"/></svg></a>
                </div>
            

            
                <div class="share-item telegram">
                    
                    <a href="https://t.me/share/url?url=https://my-hugo-blog-latin-xiao-mao.vercel.app/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/&amp;text=Java%e4%b8%ad%e4%bd%bf%e7%94%a8HSSFWorkbook%e7%94%9f%e6%88%90excel" title="Share on Telegram" target="_blank" rel="noopener"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512" class="icon telegram-icon"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm121.8 169.9l-40.7 191.8c-3 13.6-11.1 16.9-22.4 10.5l-62-45.7-29.9 28.8c-3.3 3.3-6.1 6.1-12.5 6.1l4.4-63.1 114.9-103.8c5-4.4-1.1-6.9-7.7-2.5l-142 89.4-61.2-19.1c-13.3-4.2-13.6-13.3 2.8-19.7l239.1-92.2c11.1-4 20.8 2.7 17.2 19.5z"/></svg></a>
                </div>
            

            
                <div class="share-item weibo">
                    
                    <a href="https://service.weibo.com/share/share.php?&amp;url=https://my-hugo-blog-latin-xiao-mao.vercel.app/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/&amp;title=Java%e4%b8%ad%e4%bd%bf%e7%94%a8HSSFWorkbook%e7%94%9f%e6%88%90excel&amp;pic=https://img.imgdb.cn/item/604b7e335aedab222ce6192e.jpg&amp;searchPic=false" title="Share on Weibo" target="_blank" rel="noopener"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon weibo-icon"><path d="M407 177.6c7.6-24-13.4-46.8-37.4-41.7-22 4.8-28.8-28.1-7.1-32.8 50.1-10.9 92.3 37.1 76.5 84.8-6.8 21.2-38.8 10.8-32-10.3zM214.8 446.7C108.5 446.7 0 395.3 0 310.4c0-44.3 28-95.4 76.3-143.7C176 67 279.5 65.8 249.9 161c-4 13.1 12.3 5.7 12.3 6 79.5-33.6 140.5-16.8 114 51.4-3.7 9.4 1.1 10.9 8.3 13.1 135.7 42.3 34.8 215.2-169.7 215.2zm143.7-146.3c-5.4-55.7-78.5-94-163.4-85.7-84.8 8.6-148.8 60.3-143.4 116s78.5 94 163.4 85.7c84.8-8.6 148.8-60.3 143.4-116zM347.9 35.1c-25.9 5.6-16.8 43.7 8.3 38.3 72.3-15.2 134.8 52.8 111.7 124-7.4 24.2 29.1 37 37.4 12 31.9-99.8-55.1-195.9-157.4-174.3zm-78.5 311c-17.1 38.8-66.8 60-109.1 46.3-40.8-13.1-58-53.4-40.3-89.7 17.7-35.4 63.1-55.4 103.4-45.1 42 10.8 63.1 50.2 46 88.5zm-86.3-30c-12.9-5.4-30 .3-38 12.9-8.3 12.9-4.3 28 8.6 34 13.1 6 30.8.3 39.1-12.9 8-13.1 3.7-28.3-9.7-34zm32.6-13.4c-5.1-1.7-11.4.6-14.3 5.4-2.9 5.1-1.4 10.6 3.7 12.9 5.1 2 11.7-.3 14.6-5.4 2.8-5.2 1.1-10.9-4-12.9z"/></svg></a>
                </div>
            

            
                <div class="share-item douban">
                    
                    <a href="https://www.douban.com/share/service?href=https://my-hugo-blog-latin-xiao-mao.vercel.app/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/&amp;name=Java%e4%b8%ad%e4%bd%bf%e7%94%a8HSSFWorkbook%e7%94%9f%e6%88%90excel&amp;text=HSSFWorkbook%20%e4%bb%8b%e7%bb%8d%20%e5%bc%80%e5%8f%91%e4%b8%ad%e7%bb%8f%e5%b8%b8%e4%bc%9a%e9%81%87%e5%88%b0%20Excel%20%e7%9a%84%e5%a4%84%e7%90%86%ef%bc%8c%e5%9c%a8%20Java%20%e4%b8%ad%ef%bc%8c%e6%93%8d%e4%bd%9c%20excel%20%e7%9b%ae%e5%89%8d%e6%9c%89%e4%b8%a4%e4%b8%aa%e4%b8%bb%e6%b5%81%e6%a1%86%e6%9e%b6%ef%bc%8c%e5%88%86%e5%88%ab%e6%98%af%ef%bc%9a%20apache%20%e7%9a%84%20poi%20Apache%20POI%e2%80%a6" title="Share on Douban" target="_blank" rel="noopener"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="icon douban-icon"><path d="M.643.92v2.412h22.714V.92H.643zm1.974 4.926v9.42h18.764v-9.42H2.617zm2.72 2.408H18.69v4.605H5.338V8.254zm1.657 7.412l-2.512.938c1.037 1.461 1.87 2.825 2.512 4.091H0v2.385h24v-2.385h-6.678c.818-1.176 1.589-2.543 2.303-4.091l-2.73-.938a29.952 29.952 0 01-2.479 5.03h-4.75c-.786-1.962-1.677-3.641-2.672-5.03Z"/></svg></a>
                </div>
            

            
                <div class="share-item qq">
                    
                    <a href="https://connect.qq.com/widget/shareqq/index.html?url=https://my-hugo-blog-latin-xiao-mao.vercel.app/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/&amp;title=Java%e4%b8%ad%e4%bd%bf%e7%94%a8HSSFWorkbook%e7%94%9f%e6%88%90excel&amp;summary=HSSFWorkbook%20%e4%bb%8b%e7%bb%8d%20%e5%bc%80%e5%8f%91%e4%b8%ad%e7%bb%8f%e5%b8%b8%e4%bc%9a%e9%81%87%e5%88%b0%20Excel%20%e7%9a%84%e5%a4%84%e7%90%86%ef%bc%8c%e5%9c%a8%20Java%20%e4%b8%ad%ef%bc%8c%e6%93%8d%e4%bd%9c%20excel%20%e7%9b%ae%e5%89%8d%e6%9c%89%e4%b8%a4%e4%b8%aa%e4%b8%bb%e6%b5%81%e6%a1%86%e6%9e%b6%ef%bc%8c%e5%88%86%e5%88%ab%e6%98%af%ef%bc%9a%20apache%20%e7%9a%84%20poi%20Apache%20POI%e2%80%a6&amp;pics=https://img.imgdb.cn/item/604b7e335aedab222ce6192e.jpg&amp;site=blog" title="Share on QQ" target="_blank" rel="noopener"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="icon qq-icon"><path d="M433.754 420.445c-11.526 1.393-44.86-52.741-44.86-52.741 0 31.345-16.136 72.247-51.051 101.786 16.842 5.192 54.843 19.167 45.803 34.421-7.316 12.343-125.51 7.881-159.632 4.037-34.122 3.844-152.316 8.306-159.632-4.037-9.045-15.25 28.918-29.214 45.783-34.415-34.92-29.539-51.059-70.445-51.059-101.792 0 0-33.334 54.134-44.859 52.741-5.37-.65-12.424-29.644 9.347-99.704 10.261-33.024 21.995-60.478 40.144-105.779C60.683 98.063 108.982.006 224 0c113.737.006 163.156 96.133 160.264 214.963 18.118 45.223 29.912 72.85 40.144 105.778 21.768 70.06 14.716 99.053 9.346 99.704z"/></svg></a>
                </div>
            

            
                <div class="share-item qzone">
                    
                    <a href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=https://my-hugo-blog-latin-xiao-mao.vercel.app/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel/&amp;title=Java%e4%b8%ad%e4%bd%bf%e7%94%a8HSSFWorkbook%e7%94%9f%e6%88%90excel&amp;summary=HSSFWorkbook%20%e4%bb%8b%e7%bb%8d%20%e5%bc%80%e5%8f%91%e4%b8%ad%e7%bb%8f%e5%b8%b8%e4%bc%9a%e9%81%87%e5%88%b0%20Excel%20%e7%9a%84%e5%a4%84%e7%90%86%ef%bc%8c%e5%9c%a8%20Java%20%e4%b8%ad%ef%bc%8c%e6%93%8d%e4%bd%9c%20excel%20%e7%9b%ae%e5%89%8d%e6%9c%89%e4%b8%a4%e4%b8%aa%e4%b8%bb%e6%b5%81%e6%a1%86%e6%9e%b6%ef%bc%8c%e5%88%86%e5%88%ab%e6%98%af%ef%bc%9a%20apache%20%e7%9a%84%20poi%20Apache%20POI%e2%80%a6&amp;pics=https://img.imgdb.cn/item/604b7e335aedab222ce6192e.jpg&amp;site=blog" title="Share on Qzone" target="_blank" rel="noopener"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="icon qzone-icon"><path d="M23.985 9.202c-.032-.099-.127-.223-.334-.258-.207-.036-7.351-1.406-7.351-1.406s-.105-.022-.198-.07c-.092-.047-.127-.167-.127-.167S12.447.956 12.349.77C12.25.583 12.104.532 12 .532c-.104 0-.251.051-.349.238-.098.186-3.626 6.531-3.626 6.531s-.035.12-.128.167c-.092.047-.197.07-.197.07S.556 8.908.348 8.943c-.208.036-.302.16-.333.258a.477.477 0 0 0 .125.449l5.362 5.49s.072.08.119.172c.016.104.005.21.005.21s-1.189 7.242-1.22 7.45.075.369.159.43c.083.062.233.106.421.013.189-.093 6.812-3.261 6.812-3.261s.098-.044.201-.061c.103-.017.201.061.201.061s6.623 3.168 6.812 3.261c.188.094.338.049.421-.013a.463.463 0 0 0 .159-.43c-.021-.14-.93-5.677-.93-5.677.876-.54 1.425-1.039 1.849-1.747-2.594.969-6.006 1.717-9.415 1.866-.915.041-2.41.097-3.473-.015-.678-.071-1.17-.144-1.243-.438-.053-.215.054-.46.545-.831a2640.5 2640.5 0 0 1 2.861-2.155c1.285-.968 3.559-2.47 3.559-2.731 0-.285-2.144-.781-4.037-.781-1.945 0-2.275.132-2.811.168-.488.034-.769.005-.804-.138-.06-.248.183-.389.588-.568.709-.314 1.86-.594 1.984-.626.194-.052 3.082-.805 5.618-.535 1.318.14 3.244.668 3.244 1.276 0 .342-1.721 1.494-3.225 2.597-1.149.843-2.217 1.561-2.217 1.688 0 .342 3.533 1.241 6.689 1.01l.003-.022c.048-.092.119-.172.119-.172l5.362-5.49a.477.477 0 0 0 .127-.449z"/></svg></a>
                </div>
            

            
                <div class="share-item qrcode">
                    <div class="qrcode-container" title="Share via QR Code"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="icon qrcode-icon"><path d="M0 224h192V32H0v192zM64 96h64v64H64V96zm192-64v192h192V32H256zm128 128h-64V96h64v64zM0 480h192V288H0v192zm64-128h64v64H64v-64zm352-64h32v128h-96v-32h-32v96h-64V288h96v32h64v-32zm0 160h32v32h-32v-32zm-64 0h32v32h-32v-32z"/></svg><div id="qrcode-img"></div>
                    </div>
                    <script src="https://cdn.jsdelivr.net/npm/qrcode-generator@1.4.4/qrcode.min.js"></script>

<script>
    var typeNumber = 0;
    var errorCorrectionLevel = 'L';
    var qr = qrcode(typeNumber, errorCorrectionLevel);
    qr.addData('https:\/\/my-hugo-blog-latin-xiao-mao.vercel.app\/java%E4%B8%AD%E4%BD%BF%E7%94%A8hssfworkbook%E7%94%9F%E6%88%90excel\/');
    qr.make();
    document.getElementById('qrcode-img').innerHTML = qr.createImgTag();
</script>

                </div>
            

        </div>

    </div>




        
    
    
        <div class="related-posts">
            <h2 class="related-title">See Also:<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon related-icon"><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"/></svg></h2>
            <ul class="related-list">
                
                    <li class="related-item">
                        <a href="/spring-aop%E5%AD%A6%E4%B9%A0%E4%BA%8C/" class="related-link">Spring AOP学习（二）</a>
                    </li>
                
                    <li class="related-item">
                        <a href="/spring-aop%E5%AD%A6%E4%B9%A0%E4%B8%80/" class="related-link">Spring AOP学习（一）</a>
                    </li>
                
                    <li class="related-item">
                        <a href="/java%E7%9F%A5%E8%AF%86%E7%82%B9%E4%B8%80/" class="related-link">Java知识点（一）</a>
                    </li>
                
                    <li class="related-item">
                        <a href="/%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0%E6%89%B9%E9%87%8F%E9%87%8D%E5%91%BD%E5%90%8D%E5%9B%BE%E7%89%87/" class="related-link">代码实现批量重命名图片</a>
                    </li>
                
                    <li class="related-item">
                        <a href="/java%E9%9D%A2%E8%AF%95%E9%A2%98%E4%B8%80/" class="related-link">Java面试题(一)</a>
                    </li>
                
            </ul>
        </div>
    



        
    
        <div class="post-tags">
            
                
                
                
                
                    
                    <a href="/tags/java/" rel="tag" class="post-tags-link"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon tag-icon"><path d="M0 252.118V48C0 21.49 21.49 0 48 0h204.118a48 48 0 0 1 33.941 14.059l211.882 211.882c18.745 18.745 18.745 49.137 0 67.882L293.823 497.941c-18.745 18.745-49.137 18.745-67.882 0L14.059 286.059A48 48 0 0 1 0 252.118zM112 64c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48z"/></svg>Java</a>
                
            
        </div>
    



        


        


        
    
        
        
    
    
    
    
        <ul class="post-nav">
            
                <li class="post-nav-prev">
                    <a href="/mybatis%E4%B8%ADresultmap%E7%9A%84%E4%BD%BF%E7%94%A8/" rel="prev">&lt; Mybatis中resultMap的使用</a>
                </li>
            
            
                <li class="post-nav-next">
                    <a href="/java%E4%B8%ADio%E7%AC%94%E8%AE%B0/" rel="next">Java中IO笔记 &gt;</a>
                </li>
            
        </ul>
    



        


<div class="load-comments">
    <div id="load-comments">Load Comments?</div>
</div>




<div id="vcomments"></div>







    </div>
</main>


            
    <div id="back-to-top" class="back-to-top">
        <a href="#"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="icon arrow-up"><path d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"/></svg></a>
    </div>


            
    <footer id="footer" class="footer">
        <div class="footer-inner">
            <div class="site-info">©&nbsp;2017–2021&nbsp;<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon footer-icon"><path d="M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z"/></svg>&nbsp;古月轩039</div><div class="powered-by">Powered by <a href="https://github.com/gohugoio/hugo" target="_blank" rel="noopener">Hugo</a> | Theme is <a href="https://github.com/reuixiy/hugo-theme-meme" target="_blank" rel="noopener">MemE</a></div><div class="site-copyright"><a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" target="_blank" rel="noopener">CC BY-NC-SA 4.0</a></div>

            
    
        <ul class="socials"><li class="socials-item">
                    <a href="/rss.xml" target="_blank" rel="external noopener" title="RSS"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="icon social-icon"><path d="M19.199 24C19.199 13.467 10.533 4.8 0 4.8V0c13.165 0 24 10.835 24 24h-4.801zM3.291 17.415c1.814 0 3.293 1.479 3.293 3.295 0 1.813-1.485 3.29-3.301 3.29C1.47 24 0 22.526 0 20.71s1.475-3.294 3.291-3.295zM15.909 24h-4.665c0-6.169-5.075-11.245-11.244-11.245V8.09c8.727 0 15.909 7.184 15.909 15.91z"/></svg></a>
                </li><li class="socials-item">
                    <a href="mailto:reuixiy@gmail.com" target="_blank" rel="external noopener" title="Email"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon social-icon"><path d="M464 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm0 48v40.805c-22.422 18.259-58.168 46.651-134.587 106.49-16.841 13.247-50.201 45.072-73.413 44.701-23.208.375-56.579-31.459-73.413-44.701C106.18 199.465 70.425 171.067 48 152.805V112h416zM48 400V214.398c22.914 18.251 55.409 43.862 104.938 82.646 21.857 17.205 60.134 55.186 103.062 54.955 42.717.231 80.509-37.199 103.053-54.947 49.528-38.783 82.032-64.401 104.947-82.653V400H48z"/></svg></a>
                </li><li class="socials-item">
                    <a href="https://github.com/reuixiy" target="_blank" rel="external noopener" title="GitHub"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="icon social-icon"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a>
                </li><li class="socials-item">
                    <a href="https://twitter.com/reuixiy" target="_blank" rel="external noopener" title="Twitter"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="icon social-icon"><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"/></svg></a>
                </li><li class="socials-item">
                    <a href="https://t.me/yixiuer" target="_blank" rel="external noopener" title="Telegram"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512" class="icon social-icon"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm121.8 169.9l-40.7 191.8c-3 13.6-11.1 16.9-22.4 10.5l-62-45.7-29.9 28.8c-3.3 3.3-6.1 6.1-12.5 6.1l4.4-63.1 114.9-103.8c5-4.4-1.1-6.9-7.7-2.5l-142 89.4-61.2-19.1c-13.3-4.2-13.6-13.3 2.8-19.7l239.1-92.2c11.1-4 20.8 2.7 17.2 19.5z"/></svg></a>
                </li></ul>
    



            
        </div>
    </footer>


        </div>
        

        






    

        

        
            <script>
    function loadComments() {
        if (typeof Valine === 'undefined') {
            var getScript = (options) => {
                var script = document.createElement('script');
                script.defer = true;
                script.crossOrigin = 'anonymous';
                Object.keys(options).forEach((key) => {
                    script[key] = options[key];
                });
                document.body.appendChild(script);
            };
            getScript({
                src: 'https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js',
                onload: () => {
                    newValine();
                }
            });
        } else {
            newValine();
        }
    }
    function newValine() {
        new Valine({
            el: '#vcomments',
            appId: 'SqlI8xmlWlUUkEGtN3j67uP4-gzGzoHsz',
            appKey: '7OyMfNRCyvKvNRp1ahTwfxcf',
            placeholder: '别矜持了，快来说出你的骚话吧！',
            path: location.pathname,
            avatar: '',
            meta: ["nick","mail","link"],
            pageSize:  10 ,
            lang: 'zh-CN',
            visitor:  false ,
            highlight:  true ,
            avatarForce:  false ,
            recordIP:  true ,
            serverURLs: '',
            emojiCDN: '\/\/i0.hdslb.com\/bfs\/emote\/',
            emojiMaps: {"tv_doge":"6ea59c827c414b4a2955fe79e0f6fd3dcd515e24.png","tv_亲亲":"a8111ad55953ef5e3be3327ef94eb4a39d535d06.png","tv_偷笑":"bb690d4107620f1c15cff29509db529a73aee261.png","tv_再见":"180129b8ea851044ce71caf55cc8ce44bd4a4fc8.png","tv_冷漠":"b9cbc755c2b3ee43be07ca13de84e5b699a3f101.png","tv_发怒":"34ba3cd204d5b05fec70ce08fa9fa0dd612409ff.png","tv_发财":"34db290afd2963723c6eb3c4560667db7253a21a.png","tv_可爱":"9e55fd9b500ac4b96613539f1ce2f9499e314ed9.png","tv_吐血":"09dd16a7aa59b77baa1155d47484409624470c77.png","tv_呆":"fe1179ebaa191569b0d31cecafe7a2cd1c951c9d.png","tv_呕吐":"9f996894a39e282ccf5e66856af49483f81870f3.png","tv_困":"241ee304e44c0af029adceb294399391e4737ef2.png","tv_坏笑":"1f0b87f731a671079842116e0991c91c2c88645a.png","tv_大佬":"093c1e2c490161aca397afc45573c877cdead616.png","tv_大哭":"23269aeb35f99daee28dda129676f6e9ea87934f.png","tv_委屈":"d04dba7b5465779e9755d2ab6f0a897b9b33bb77.png","tv_害羞":"a37683fb5642fa3ddfc7f4e5525fd13e42a2bdb1.png","tv_尴尬":"7cfa62dafc59798a3d3fb262d421eeeff166cfa4.png","tv_微笑":"70dc5c7b56f93eb61bddba11e28fb1d18fddcd4c.png","tv_思考":"90cf159733e558137ed20aa04d09964436f618a1.png","tv_惊吓":"0d15c7e2ee58e935adc6a7193ee042388adc22af.png"},
            enableQQ:  true ,
            requiredFields: ["nick","mail"]
        });
    }
</script>

        

        

    



    <script src="https://cdn.jsdelivr.net/npm/medium-zoom@latest/dist/medium-zoom.min.js"></script>

<script>
    mediumZoom(document.querySelectorAll('div.post-body img'), {
        background: 'hsla(var(--color-bg-h), var(--color-bg-s), var(--color-bg-l), 0.95)'
    })
</script>




    <script src="https://cdn.jsdelivr.net/npm/instant.page@5.1.0/instantpage.min.js" type="module" defer></script>







    </body>
</html>
